package com.leetcode;

import org.junit.Test;

import java.util.Arrays;
import java.util.HashSet;

/**
 * Created by Z-hong on 2022/9/30.
 */

public class LeetCode面试0108 {
    public void setZeroes(int[][] matrix) {
        HashSet<Integer> setM = new HashSet<>();
        HashSet<Integer> setN = new HashSet<>();
        int [] m=new int[matrix.length];
        int [] n=new int[matrix[0].length];
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                if (matrix[i][j]==0){
                    setM.add(i);
                    setN.add(j);
                }
            }
        }
        for (Integer integer : setM) {
            matrix[integer]=n;
        }

        for (Integer integer : setN) {
            for (int i = 0; i < matrix.length; i++) {
                matrix[i][(int)integer]=0;
            }
        }


    }

    @Test
    public void test(){
        int[][]arr= {{1,1,1,8},{1,0,1,0},{0,1,1,1}};
        setZeroes(arr);
        System.out.println(Arrays.toString(arr));
    }
}
